package com.feemanage.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.common.core.page.PageDomain;
import com.common.core.page.TableDataInfo;
import com.common.utils.poi.ExcelUtil;
import com.feemanage.domain.BizProjectFeeCard;
import com.feemanage.domain.vo.BizProjectFeeCardVo;
import com.feemanage.service.IBizProjectFeeCardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 项目经费卡
 */
@Api(tags="项目经费卡")
@RestController
@RequestMapping("/feemanage/feecard")
public class BizProjectFeeCardController {

    @Autowired
    private IBizProjectFeeCardService baseService;

    /**
     * 查询列表
     * @param pageDomain
     * @param feeCard
     * @return
     */
    @ApiOperation("查询列表")
    @GetMapping("/list")
    public TableDataInfo list(PageDomain pageDomain, BizProjectFeeCard feeCard){
        IPage<BizProjectFeeCardVo> page = baseService.selectList(pageDomain,feeCard);
        return TableDataInfo.build(page.getRecords(),page.getTotal());
    }

    /**
     * 导出项目经费卡列表
     */
    @ApiOperation("导出项目经费卡列表")
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestBody PageDomain pageDomain, @RequestBody BizProjectFeeCard feeCard)
    {
        List<BizProjectFeeCardVo> list = baseService.selectExportList(pageDomain,feeCard);
        ExcelUtil<BizProjectFeeCardVo> util = new ExcelUtil<>(BizProjectFeeCardVo.class);
        util.exportExcel(response, list, "项目经费卡列表");
    }
}
